package de.fhin.mas.agents.manager.behaviours;

import jade.domain.FIPAAgentManagement.FailureException;
import jade.domain.FIPAAgentManagement.NotUnderstoodException;
import jade.domain.FIPAAgentManagement.RefuseException;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;
import jade.proto.AchieveREResponder;
import de.fhin.mas.MASEvents;
import de.fhin.mas.agents.manager.ManagerAgent;

public class ServeResume extends AchieveREResponder {
	private static final long serialVersionUID = -3012487599688258180L;
	private final ManagerAgent managerAgent;

	public ServeResume(ManagerAgent a) {
		// TODO: Auf Topic umstellen
		super(a, MessageTemplate.and(MessageTemplate.MatchConversationId("init_" + MASEvents.RESUME.getName()),
				MessageTemplate.MatchPerformative(ACLMessage.REQUEST)));
		managerAgent = a;
	}

	@Override
	protected ACLMessage handleRequest(ACLMessage request) throws NotUnderstoodException, RefuseException {
		return super.handleRequest(request);
	}

	@Override
	protected ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response) throws FailureException {
		managerAgent.initResume();
		return new ACLMessage(ACLMessage.INFORM);
	}
}
